/* 8911106 302933981 Ofri Keidar */

/******************************************************************************
* Student Name: Ofri Keidar
* Exercise Name: Ex6
* File Description: Class Order's implementaion
******************************************************************************/


#include "Order.h"

/***************************************************************************************
* function name: Order(const int orderNum, const short itemNum, const unsigned short amount)
* The Input: Order number, Number of item to be ordered and amount to be ordered
* The output: None
* The Function operation: Initializes new Order object's attributes with given values
***************************************************************************************/
Order::Order(const int orderNum, const short itemNum, const unsigned short amount): m_orderNum(orderNum), m_itemNum(itemNum), m_amountOrdered(amount) {
	m_amountLeft = amount; // no items have been received yet
}

/***************************************************************************************
* function name: Order(const Order& orderToCopy)
* The Input: Order object to be copied
* The output: None
* The Function operation: Empty implementation since an order should not be copied
***************************************************************************************/
Order::Order(const Order& orderToCopy): m_orderNum(orderToCopy.m_orderNum), m_itemNum(orderToCopy.m_itemNum),
						         m_amountOrdered(orderToCopy.m_amountOrdered) {
	m_amountLeft = orderToCopy.m_amountLeft;
}

/***************************************************************************************
 * function name: friend ostream& operator << (ostream &os, const Order& orderToPrint)
 * The Input: Reference to order to be printed
 * The output: ostream reference
 * The Function operation: Prints order's attributes in format [order-number, ordered-amount, receive-amount]
 ***************************************************************************************/
ostream& operator << (ostream &os, const Order& orderToPrint) {
	cout << "[" << orderToPrint.m_orderNum << "," << orderToPrint.m_amountOrdered << "," << orderToPrint.m_amountLeft << "]";
	return os;
}
